var express = require('express');
var router = express.Router();
const fs = require('fs');
const path=require('path')
// const {
//   path
// } = require('../app');

/* GET home page. */
router.get('/', function (req, res, next) {

  // render绘制渲染视图
  res.render('index', {
    title: '当<del>快乐</del>结束，冷漠开始',
    content: '没有<del>原因</del>，不需要任何理由,大家都默默地遵守',
    el: ['单薄透明的玻璃', '隔着两方世界', '没人反抗', '没人逃走']
  });
});

router.get("/pic", (req, res) => {
  // fs.readdir(path.resolve("asess/pic"))
  // console.log(path.resolve("asess/pic"));
  let readRes = fs.readdirSync(path.resolve("asess/pic"))
  // console.log(readRes);
  // res.send("qqqqqq")
  // 过滤掉 .DS_Store这个文件
  readRes = readRes.filter((item, index) => {
    return index !== 0;
  })
  console.log(readRes);

  // 调用视图引擎
  res.render("pic",{asessPath:"/pic/",data:readRes})
})

module.exports = router;